| Method | Request URI |
|---|---|
| POST | /API/LogOn/Token/ |
This example will get a logon token with for local user1 who has a password of "1234".
using System.Net;
using System.Net.Http;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Web.Script.Serialization;
...
using (HttpClient httpClient = new HttpClient())
{
string url = "http://localhost:8004/API/LogOn/Token/";
// Define the request body
HttpContent requestBody = null;
requestBody =
new StringContent(@"
{
""accountName"": ""user1"",
""password"": ""1234"",
""isWindowsLogOn"": false
}
",Encoding.UTF8,"application/json");
using (var response = httpClient.PostAsync(url, requestBody).Result)
{
if(response.StatusCode == HttpStatusCode.OK)
{
Console.WriteLine("Success");
// A Dundas.BI.WebApi.Models
// GetLogOnTokenResultData object as a JSON
// string.
string jsonObject = response.Content.ReadAsStringAsync().Result;
}
}
}
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.apache.http.entity.StringEntity;
import org.json.JSONObject;
...
HttpClient httpClient = HttpClientBuilder.create().build();
String url = "http://localhost:8004";
String requestUrl = "http://localhost:8004/API/LogOn/Token/";
// Define the Request Method.
HttpPost requstMethod = new HttpPost(requestUrl);
// Define the Request Body.
StringEntity input =
new StringEntity(
"{"
+ " \"accountName\": \"user1\","
+ " \"password\": \"1234\","
+ " \"isWindowsLogOn\": false "
+ "}"
);
input.setContentType("application/json");
requstMethod.setEntity(input);
HttpResponse response =
httpClient.execute(requstMethod);
if(response.getStatusLine().getStatusCode() == 200)
{
System.out.println("Success");
}
// A Dundas.BI.WebApi.Models
// GetLogOnTokenResultData object as a JSON
// string.
String json = EntityUtils.toString(response.getEntity());
var dataObject =
{
"accountName": "user1",
"password": "1234",
"isWindowsLogOn": false
};
$.ajax({
type: "POST",
url: baseUrl + "/API/LogOn/Token/",
data: JSON.stringify(dataObject),
contentType: "application/json",
success: function(data) {
// data = A Dundas.BI.WebApi.Models
// GetLogOnTokenResultData object.
},
error: function(data) { alert('failed' + data); }
});
This example will get a logon token with for local user1 from a privileged service account with username adminsvc and password 4321.
using System.Net;
using System.Net.Http;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Web.Script.Serialization;
...
using (HttpClient httpClient = new HttpClient())
{
string url = "http://localhost:8004/API/LogOn/Token/";
// Define the request body
HttpContent requestBody = null;
requestBody =
new StringContent(@"
{
""effectiveAccountName"": ""user1"",
""accountName"": ""adminsvc"",
""password"": ""4321"",
""isWindowsLogOn"": false
}
",Encoding.UTF8,"application/json");
using (var response = httpClient.PostAsync(url, requestBody).Result)
{
if(response.StatusCode == HttpStatusCode.OK)
{
Console.WriteLine("Success");
// A Dundas.BI.WebApi.Models
// GetLogOnTokenResultData object as a JSON
// string.
string jsonObject = response.Content.ReadAsStringAsync().Result;
}
}
}
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.apache.http.entity.StringEntity;
import org.json.JSONObject;
...
HttpClient httpClient = HttpClientBuilder.create().build();
String url = "http://localhost:8004";
String requestUrl = "http://localhost:8004/API/LogOn/Token/";
// Define the Request Method.
HttpPost requstMethod = new HttpPost(requestUrl);
// Define the Request Body.
StringEntity input =
new StringEntity(
"{"
+ " \"effectiveAccountName\": \"user1\","
+ " \"accountName\": \"adminsvc\","
+ "\"password\": \"4321\","
+ " \"isWindowsLogOn\": false "
+ "}"
);
input.setContentType("application/json");
requstMethod.setEntity(input);
HttpResponse response =
httpClient.execute(requstMethod);
if(response.getStatusLine().getStatusCode() == 200)
{
System.out.println("Success");
}
// A Dundas.BI.WebApi.Models
// GetLogOnTokenResultData object as a JSON
// string.
String json = EntityUtils.toString(response.getEntity());
var dataObject =
{
"effectiveAccountName": "user1",
"accountName": "adminsvc",
"password": "4321",
"isWindowsLogOn": false
};
$.ajax({
type: "POST",
url: baseUrl + "/API/LogOn/Token/",
data: JSON.stringify(dataObject),
contentType: "application/json",
success: function(data) {
// data = A Dundas.BI.WebApi.Models
// GetLogOnTokenResultData object.
},
error: function(data) { alert('failed' + data); }
});